Skip to content

chore: improve e2e signalling test tooling#1998

Merged
lukasIO merged 14 commits into
mainfrom
lukas/signal-e2e
Jul 27, 2026
Merged

chore: improve e2e signalling test tooling#1998
lukasIO merged 14 commits into
mainfrom
lukas/signal-e2e

Conversation

@lukasIO

@lukasIO lukasIO commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

client side for livekit/livekit#4653

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ab462dc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

github-advanced-security[bot]

This comment was marked as resolved.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 104.62 KB (0%)
dist/livekit-client.umd.js 113.68 KB (0%)

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@1egoman 1egoman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally makes sense to me!

Just wanted to confirm one thing to make sure I am reading this right - running npm test wouldn't cause the e2e tests to run by default correct? You'd need to explictly run test:e2e and set the relevant LK_ prefixed env vars to the server environment?

Comment thread src/api/SignalClient.e2e.test.ts Outdated
websocketTimeout: 5_000,
});

const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: could this be imported from here instead?

Comment on lines +72 to +80
it('stays connected past the ping timeout while the server pongs', async () => {
const onClose = vi.fn();
await join('happy');
client.onClose = onClose;
// Server ping timeout is 3s; a healthy pong loop must keep us alive.
await sleep(4_000);
expect(onClose).not.toHaveBeenCalled();
expect(client.currentState).toBe(SignalConnectionState.CONNECTED);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I added this subscribeToEvents test helper here when building data tracks (and I've also used it in the data streams v2 pr). I found it really nice for testing classes which emit events rather than manually registering / unregistering vi.fn() type mocks.

I realize SignalClient isn't an EventEmitter today but that helper looks like it could maybe be useful here as well. If you agree, maybe it should be converted to an EventEmitter and used here too.

If you want to invest in this subscribeToEvents helper more, it might be worth also adding something in the AGENTS.md file about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave converting SignalClient to an EventEmitter for a potential follow up

Comment thread src/api/SignalClient.e2e.test.ts
Comment thread src/api/SignalClient.e2e.test.ts
Comment thread src/api/SignalClient.e2e.test.ts Outdated
const binary = join(serverDir, 'bin', 'test-server');
if (!process.env.LK_E2E_SKIP_BUILD) {
try {
execFileSync('go', ['build', '-o', 'bin/test-server', './cmd/test-server'], {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question(non-blocking): is this guaranteed to always be the right command, or would it be better to call out to some sort build tool (maybe mage? Or maybe a bespoke script?) in the livekit/livekit repo?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still am somewhat curious here, is there a more robust way to handle this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the command that is also used in the server repo for the test server.
note that this is only ever used for local tests against custom server changes if we're not pulling in the existing docker image (which is what the CI does).

Comment thread src/test/signalToken.ts
ttlSeconds?: number;
}

export async function createToken(opts: TokenOptions = {}): Promise<string> {

@1egoman 1egoman Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question(non-blocking): would it be a good idea to pull in the node server sdk as a dev dependency to generate this token? Or would that be nonviable since you need to add the custom lk.mock attribute?

I mostly bring it up because this could potentially silently break if new fields were added to tokens that should be included by default in newly generated ones. Relying on the existing library should make that a non issue.

Comment thread pnpm-workspace.yaml
Comment thread vitest.e2e.config.mts
Comment on lines +17 to +22
browser: {
enabled: true,
provider: playwright(),
headless: true,
instances: [{ browser: 'chromium' }],
},

@1egoman 1egoman Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Is there benefit to running this across multiple browsers? Guessing not for signaling, but maybe there could be for the follow up peer connection management state machine work?

Comment on lines +46 to +50
- name: Run signal e2e tests
run: pnpm test:e2e 2>&1 | tee e2e.log
env:
# Connect to the test-server service above (validate + WS on 9999).
LK_TEST_SERVER_URL: ws://127.0.0.1:9999

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Just curious, how stable have these been so far in ci?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very stable so far!

@lukasIO
lukasIO requested a review from 1egoman July 24, 2026 14:58
const binary = join(serverDir, 'bin', 'test-server');
if (!process.env.LK_E2E_SKIP_BUILD) {
try {
execFileSync('go', ['build', '-o', 'bin/test-server', './cmd/test-server'], {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still am somewhat curious here, is there a more robust way to handle this?

@lukasIO lukasIO changed the title add e2e signalling tests chore: improve e2e signalling test tooling Jul 27, 2026
@lukasIO
lukasIO merged commit 042f1c1 into main Jul 27, 2026
6 checks passed
@lukasIO
lukasIO deleted the lukas/signal-e2e branch July 27, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants